package persondog

class Person2(var name:String){
  def makeFriends(p:Person2): Unit ={
    println(this.name +" 和 " + p.name + "交朋友")
  }
}
class Dog(var name :String)

class Party[T <% Person2](var p1:Person2, var p2:Person2){
  def play():Unit={
    p1.makeFriends(p2)
  }
}

object PersonDogPredef{
  implicit  def dog2person(dog:Dog) : Person2={
    new Person2(dog.name)
  }
}

object PersonDogMakeFriendsDemo {
  def main(args: Array[String]): Unit = {
    val erlangshen = new Person2("二郎神")
    val xiaotianquan= new Dog("哮天犬")
    import  PersonDogPredef._
    val party = new Party[Person2](erlangshen, xiaotianquan)
    party.play()
  }
}
